package edu.mama.college.mapper;

import edu.mama.college.model.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 用户类的MyBatis操作接口
 */
@Mapper
public interface UserMapper {

    /**
     * 用户登录（根据手机号和密码进行匹配）
     * @param mobile
     * @param password
     * @return
     */
    @Select("SELECT * FROM user WHERE mobile = #{mobile} and password = #{password}")
    User findByMobileAndPassword(@Param("mobile") String mobile,
                                 @Param("password") String password);

    /**
     * 用户注册
     * @param user
     */
    @Select("INSERT INTO user (mobile, password) VALUES (#{mobile}, #{password})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void register(User user);
}
